//
//  NavgationSearchView.m
//  Fireball
//
//  Created by 俞渊华 on 2017/12/4.
//  Copyright © 2017年 俞渊华. All rights reserved.
//

#import "NavgationSearchView.h"

@interface NavgationSearchView ()
@property(nonatomic, strong)UIButton *searchButton;
@end

@implementation NavgationSearchView

-(instancetype)initWithFrame:(CGRect)frame{
    if ([super initWithFrame:frame]) {

        self.searchButton = [UIButton buttonWithType:UIButtonTypeCustom];
        self.searchButton.backgroundColor = [UIColor xm_colorFromRGB:0xf8f8f8];
        [self.searchButton setTitle:@"搜索个关键词试试" forState:UIControlStateNormal];
        self.searchButton.titleLabel.font = [UIFont xm_font:13.0];
        [self.searchButton setTitleColor:[UIColor xm_colorFromRGB:0xB4B4B4] forState:UIControlStateNormal];
        [self.searchButton setImage:[UIImage imageNamed:@"home_seach"] forState:UIControlStateNormal];
        self.searchButton.contentHorizontalAlignment = UIControlContentHorizontalAlignmentLeft;
        [self addSubview:self.searchButton];
        [self.searchButton addTarget:self action:@selector(searchButtonClick) forControlEvents:UIControlEventTouchUpInside];
        
        self.searchButton.imageEdgeInsets = UIEdgeInsetsMake(0, 10, 0, 0);
        self.searchButton.titleEdgeInsets = UIEdgeInsetsMake(0, 15, 0, 0);

        self.searchButton.clipsToBounds = YES;
        self.searchButton.layer.cornerRadius = 15.0;
    }
    return self;
}
-(void)searchButtonClick{
    if (self.delegate && [self.delegate respondsToSelector:@selector(homePageNavigationSearchClick)]) {
        [self.delegate homePageNavigationSearchClick];
    }

}
-(void)layoutSubviews{
    [super layoutSubviews];
    
    [self.searchButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.centerY.mas_equalTo(self);
        make.height.mas_equalTo(@30);
    }];
}



@end
